package com.lmc.form.script;

import com.free.bsf.core.util.StringUtils;
import com.free.bsf.core.util.WebUtils;
import lombok.val;

import java.util.ArrayList;
import java.util.List;

public class DebugUtil {
    public static void webDebug(Object info){
        val request = WebUtils.getRequest();
        if(request!=null) {
            val debug = getWebDebug();
            debug.add(info);
            request.setAttribute("FormDynamicScriptDebug", debug);
        }else{
            //非web请求，不输出
        }
    }
    public static List<Object> getWebDebug(){
        val request = WebUtils.getRequest();
        val debug = request.getAttribute("FormDynamicScriptDebug");
        if(debug == null)
            return new ArrayList<>();
        else
            return (ArrayList)debug;
    }
}
